<template>
  <el-table
      :data="tableData"
      size="medium" 
      border
      max-height='500px'
      highlight-current-row
      v-loading="tableLoading"
      stripe
      @row-click="rowClick">
      <el-table-column
        type="index"
        label='序号'
        align="center"
        width="70">
      </el-table-column>
      <el-table-column
        align="center"
        v-for="(item) in headerList"
        :key="item.prop"
        :prop="item.prop"
        :label="item.label"
        :min-width="item.width"
        show-overflow-tooltip>
        <template slot-scope="scope">
          <template v-if="item.prop === 'departments_id'">
            {{ scope.row.department?scope.row.department.name:'' }}
          </template>
          <!-- <template v-else-if="item.prop === 'status'">
            {{ projectStatus(scope.row) }}
          </template> -->
          <template v-else-if="item.prop === 'leader'">
            {{ scope.row.leader_info ? scope.row.leader_info.name : scope.row.leader }}
          </template>
          <template v-else-if="item.prop === 'contract_type'">
            {{contractTypeObj[scope.row.contract_type]}}
          </template>
          <template v-else-if="item.prop === 'paper_type'">
            {{paperTypeObj[scope.row.paper_type]}}
          </template>
          <template v-else>
           {{ scope.row[item.prop] }}
          </template>
        </template>
      </el-table-column>
    </el-table>
</template>

<script>
import {reviewStatusObj,reviewerTypeObj,contractTypeObj,paperTypeObj} from "@/assets/js"
export default {
    props:{
        headerList:{
            default: ()=>([]),
            type: Array
        },
        tableData:{
            default: ()=>([]),
            type: Array
        },
        tableLoading:{
            default: true,
            type: Boolean
        }
    },
    data(){
      return{
        contractTypeObj,
        paperTypeObj
      }
    },
    methods:{
      rowClick(row){
        this.$emit('info',row)
      },
      echoStatus(value){
        let i
        if(value.review){
          i = value.review.review_status
        }else{
          i = value.review_status
        }
        return reviewStatusObj[i]
      },
      projectStatus(value){
        let i = value.review.review_status,
            j = value.review.reviewer_type

        return reviewerTypeObj[j] + reviewStatusObj[i]
      }
    }
}
</script>

<style>

</style>